<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Aria: actionExample.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Aria
   &#160;<span id="projectnumber">2.9.4</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('actionExample_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">actionExample.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>An example program demonstrating how to make and use new actions.This example program creates two new actions, Go and Turn. Go will drive the robot forward safely, while Turn will avoid obstacles detected by the sonar by turning. This program also adds a predefined action from <a class="el" href="classAria.html" title="Contains global initialization, deinitialization and other global functions. ">Aria</a> which tries to recover from stalls (hit something and can't move forward) by backing and turning.</p>
<p>Each of these actions have the normal constructor and destructor, note that the constructors use constructor chaining to create their <a class="el" href="classArAction.html" title="Base class for actions. ">ArAction</a> part correctly. Each action then also implements the essential virtual method, fire(). This fire function is called by the action resolver, and returns values that, in combination with other actions' desired behavior, determine the driving commands sent to the robot.</p>
<p>Also note that each of these actions override the setRobot function; these implementations obtain the sonar device from the robot in addition to doing the needed caching of the robot pointer. This is what you should do if you care about the presence or absence of a particular sensor. If you don't care about any particular sensor you could just use one of the checkRangeDevice... methods in <a class="el" href="classArRobot.html" title="Central class for communicating with and operating the robot. ">ArRobot</a> (there are four of them). Also note that these are very naive actions, they are simply an example of how to use actions.</p>
<p>See the <a class="el" href="index.html#actions">Actions</a> Actions section of the <a class="el" href="classAria.html" title="Contains global initialization, deinitialization and other global functions. ">Aria</a> reference manual overview for more details about actions.</p>
<p>Note that actions must take a small amount of time to execute, to avoid delaying the robot synchronization cycle.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;Aria.h&quot;</span></div><div class="line"></div><div class="line"><span class="comment">/* </span></div><div class="line"><span class="comment"> * Action that drives the robot forward, but stops if obstacles are</span></div><div class="line"><span class="comment"> * detected by sonar. </span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keyword">class </span>ActionGo : <span class="keyword">public</span> <a name="_a0"></a><a class="code" href="classArAction.html">ArAction</a></div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">  <span class="comment">// constructor, sets myMaxSpeed and myStopDistance</span></div><div class="line">  ActionGo(<span class="keywordtype">double</span> maxSpeed, <span class="keywordtype">double</span> stopDistance);</div><div class="line">  <span class="comment">// destructor. does not need to do anything</span></div><div class="line">  <span class="keyword">virtual</span> ~ActionGo(<span class="keywordtype">void</span>) {};</div><div class="line">  <span class="comment">// called by the action resolver to obtain this action&#39;s requested behavior</span></div><div class="line">  <span class="keyword">virtual</span> <a name="_a1"></a><a class="code" href="classArActionDesired.html">ArActionDesired</a> *<a name="a2"></a><a class="code" href="classArAction.html#a900675ede8563489ccc2e7e0934670bb">fire</a>(<a class="code" href="classArActionDesired.html">ArActionDesired</a> currentDesired);</div><div class="line">  <span class="comment">// store the robot pointer, and it&#39;s ArSonarDevice object, or deactivate this action if there is no sonar.</span></div><div class="line">  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a name="a3"></a><a class="code" href="classArAction.html#a51b27da0403d43cd916cbf49ba7ddc23">setRobot</a>(<a name="_a4"></a><a class="code" href="classArRobot.html">ArRobot</a> *robot);</div><div class="line"><span class="keyword">protected</span>:</div><div class="line">  <span class="comment">// the sonar device object obtained from the robot by setRobot()</span></div><div class="line">  <a name="_a5"></a><a class="code" href="classArRangeDevice.html">ArRangeDevice</a> *mySonar;</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">/* Our current desired action: fire() modifies this object and returns</span></div><div class="line"><span class="comment">      to the action resolver a pointer to this object.</span></div><div class="line"><span class="comment">      This object is kept as a class member so that it persists after fire()</span></div><div class="line"><span class="comment">      returns (otherwise fire() would have to create a new object each invocation,</span></div><div class="line"><span class="comment">      but would never be able to delete that object).</span></div><div class="line"><span class="comment">  */</span></div><div class="line">  <a class="code" href="classArActionDesired.html">ArActionDesired</a> myDesired;</div><div class="line"></div><div class="line">  <span class="keywordtype">double</span> myMaxSpeed;</div><div class="line">  <span class="keywordtype">double</span> myStopDistance;</div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/* Action that turns the robot away from obstacles detected by the </span></div><div class="line"><span class="comment"> * sonar. */</span></div><div class="line"><span class="keyword">class </span>ActionTurn : <span class="keyword">public</span> <a class="code" href="classArAction.html">ArAction</a></div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">  <span class="comment">// constructor, sets the turnThreshold, and turnAmount</span></div><div class="line">  ActionTurn(<span class="keywordtype">double</span> turnThreshold, <span class="keywordtype">double</span> turnAmount);</div><div class="line">  <span class="comment">// destructor, its just empty, we don&#39;t need to do anything</span></div><div class="line">  <span class="keyword">virtual</span> ~ActionTurn(<span class="keywordtype">void</span>) {};</div><div class="line">  <span class="comment">// fire, this is what the resolver calls to figure out what this action wants</span></div><div class="line">  <span class="keyword">virtual</span> <a class="code" href="classArActionDesired.html">ArActionDesired</a> *fire(<a class="code" href="classArActionDesired.html">ArActionDesired</a> currentDesired);</div><div class="line">  <span class="comment">// sets the robot pointer, also gets the sonar device, or deactivates this action if there is no sonar.</span></div><div class="line">  <span class="keyword">virtual</span> <span class="keywordtype">void</span> setRobot(<a class="code" href="classArRobot.html">ArRobot</a> *robot);</div><div class="line"><span class="keyword">protected</span>:</div><div class="line">  <span class="comment">// this is to hold the sonar device form the robot</span></div><div class="line">  <a class="code" href="classArRangeDevice.html">ArRangeDevice</a> *mySonar;</div><div class="line">  <span class="comment">// what the action wants to do; used by the action resover after fire()</span></div><div class="line">  <a class="code" href="classArActionDesired.html">ArActionDesired</a> myDesired;</div><div class="line">  <span class="comment">// distance at which to start turning</span></div><div class="line">  <span class="keywordtype">double</span> myTurnThreshold;</div><div class="line">  <span class="comment">// amount to turn when turning is needed</span></div><div class="line">  <span class="keywordtype">double</span> myTurnAmount;</div><div class="line">  <span class="comment">// remember which turn direction we requested, to help keep turns smooth</span></div><div class="line">  <span class="keywordtype">int</span> myTurning; <span class="comment">// -1 == left, 1 == right, 0 == none</span></div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Note the use of constructor chaining with </span></div><div class="line"><span class="comment">  ArAction(actionName). Also note how it uses setNextArgument, which makes it so that </span></div><div class="line"><span class="comment">  other parts of the program could find out what parameters this action has, and possibly modify them.</span></div><div class="line"><span class="comment">*/</span></div><div class="line">ActionGo::ActionGo(<span class="keywordtype">double</span> maxSpeed, <span class="keywordtype">double</span> stopDistance) :</div><div class="line">  <a class="code" href="classArAction.html">ArAction</a>(<span class="stringliteral">&quot;Go&quot;</span>)</div><div class="line">{</div><div class="line">  mySonar = NULL;</div><div class="line">  myMaxSpeed = maxSpeed;</div><div class="line">  myStopDistance = stopDistance;</div><div class="line">  setNextArgument(<a name="_a6"></a><a class="code" href="classArArg.html">ArArg</a>(<span class="stringliteral">&quot;maximum speed&quot;</span>, &amp;myMaxSpeed, <span class="stringliteral">&quot;Maximum speed to go.&quot;</span>));</div><div class="line">  setNextArgument(<a class="code" href="classArArg.html">ArArg</a>(<span class="stringliteral">&quot;stop distance&quot;</span>, &amp;myStopDistance, <span class="stringliteral">&quot;Distance at which to stop.&quot;</span>));</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Override ArAction::setRobot() to get the sonar device from the robot, or deactivate this action if it is missing.</span></div><div class="line"><span class="comment">  You must also call ArAction::setRobot() to properly store</span></div><div class="line"><span class="comment">  the ArRobot pointer in the ArAction base class.</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><span class="keywordtype">void</span> ActionGo::setRobot(<a class="code" href="classArRobot.html">ArRobot</a> *robot)</div><div class="line">{</div><div class="line">  <a class="code" href="classArAction.html#a51b27da0403d43cd916cbf49ba7ddc23">ArAction::setRobot</a>(robot);</div><div class="line">  mySonar = robot-&gt;<a name="a7"></a><a class="code" href="classArRobot.html#a1f42bf67e357145f7f60d7ff3f8226c7">findRangeDevice</a>(<span class="stringliteral">&quot;sonar&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (robot == NULL)</div><div class="line">    {</div><div class="line">      <a name="a8"></a><a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a9"></a><a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;actionExample: ActionGo: Warning: I found no sonar, deactivating.&quot;</span>);</div><div class="line">      deactivate();</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  This fire is the whole point of the action.</span></div><div class="line"><span class="comment">  currentDesired is the combined desired action from other actions</span></div><div class="line"><span class="comment">  previously processed by the action resolver.  In this case, we&#39;re</span></div><div class="line"><span class="comment">  not interested in that, we will set our desired </span></div><div class="line"><span class="comment">  forward velocity in the myDesired member, and return it.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  Note that myDesired must be a class member, since this method</span></div><div class="line"><span class="comment">  will return a pointer to myDesired to the caller. If we had</span></div><div class="line"><span class="comment">  declared the desired action as a local variable in this method,</span></div><div class="line"><span class="comment">  the pointer we returned would be invalid after this method</span></div><div class="line"><span class="comment">  returned.</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><a class="code" href="classArActionDesired.html">ArActionDesired</a> *ActionGo::fire(<a class="code" href="classArActionDesired.html">ArActionDesired</a> currentDesired)</div><div class="line">{</div><div class="line">  <span class="keywordtype">double</span> range;</div><div class="line">  <span class="keywordtype">double</span> speed;</div><div class="line"></div><div class="line">  <span class="comment">// reset the actionDesired (must be done), to clear</span></div><div class="line">  <span class="comment">// its previous values.</span></div><div class="line">  myDesired.<a name="a10"></a><a class="code" href="classArActionDesired.html#ade8f095f408b4ed5e638bb4a72ad070b">reset</a>();</div><div class="line"></div><div class="line">  <span class="comment">// if the sonar is null we can&#39;t do anything, so deactivate</span></div><div class="line">  <span class="keywordflow">if</span> (mySonar == NULL)</div><div class="line">  {</div><div class="line">    deactivate();</div><div class="line">    <span class="keywordflow">return</span> NULL;</div><div class="line">  }</div><div class="line">  <span class="comment">// get the range of the sonar</span></div><div class="line">  range = mySonar-&gt;currentReadingPolar(-70, 70) - myRobot-&gt;getRobotRadius();</div><div class="line">  <span class="comment">// if the range is greater than the stop distance, find some speed to go</span></div><div class="line">  <span class="keywordflow">if</span> (range &gt; myStopDistance)</div><div class="line">  {</div><div class="line">    <span class="comment">// just an arbitrary speed based on the range</span></div><div class="line">    speed = range * .3;</div><div class="line">    <span class="comment">// if that speed is greater than our max, cap it</span></div><div class="line">    <span class="keywordflow">if</span> (speed &gt; myMaxSpeed)</div><div class="line">      speed = myMaxSpeed;</div><div class="line">    <span class="comment">// now set the velocity</span></div><div class="line">    myDesired.setVel(speed);</div><div class="line">  }</div><div class="line">  <span class="comment">// the range was less than the stop distance, so request stop</span></div><div class="line">  <span class="keywordflow">else</span></div><div class="line">  {</div><div class="line">    myDesired.setVel(0);</div><div class="line">  }</div><div class="line">  <span class="comment">// return a pointer to the actionDesired to the resolver to make our request</span></div><div class="line">  <span class="keywordflow">return</span> &amp;myDesired;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  This is the ActionTurn constructor, note the use of constructor chaining </span></div><div class="line"><span class="comment">  with the ArAction. also note how it uses setNextArgument, which makes </span></div><div class="line"><span class="comment">  it so that other things can see what parameters this action has, and </span></div><div class="line"><span class="comment">  set them.  It also initializes the classes variables.</span></div><div class="line"><span class="comment">*/</span></div><div class="line">ActionTurn::ActionTurn(<span class="keywordtype">double</span> turnThreshold, <span class="keywordtype">double</span> turnAmount) :</div><div class="line">  <a class="code" href="classArAction.html">ArAction</a>(<span class="stringliteral">&quot;Turn&quot;</span>)</div><div class="line">{</div><div class="line">  myTurnThreshold = turnThreshold;</div><div class="line">  myTurnAmount = turnAmount;</div><div class="line">  setNextArgument(<a class="code" href="classArArg.html">ArArg</a>(<span class="stringliteral">&quot;turn threshold (mm)&quot;</span>, &amp;myTurnThreshold, <span class="stringliteral">&quot;The number of mm away from obstacle to begin turnning.&quot;</span>));</div><div class="line">  setNextArgument(<a class="code" href="classArArg.html">ArArg</a>(<span class="stringliteral">&quot;turn amount (deg)&quot;</span>, &amp;myTurnAmount, <span class="stringliteral">&quot;The number of degress to turn if turning.&quot;</span>));</div><div class="line">  myTurning = 0;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Sets the myRobot pointer (all setRobot overloaded functions must do this),</span></div><div class="line"><span class="comment">  finds the sonar device from the robot, and if the sonar isn&#39;t there, </span></div><div class="line"><span class="comment">  then it deactivates itself.</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><span class="keywordtype">void</span> ActionTurn::setRobot(<a class="code" href="classArRobot.html">ArRobot</a> *robot)</div><div class="line">{</div><div class="line">  <a class="code" href="classArAction.html#a51b27da0403d43cd916cbf49ba7ddc23">ArAction::setRobot</a>(robot);</div><div class="line">  mySonar = robot-&gt;<a class="code" href="classArRobot.html#a1f42bf67e357145f7f60d7ff3f8226c7">findRangeDevice</a>(<span class="stringliteral">&quot;sonar&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (mySonar == NULL)</div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;actionExample: ActionTurn: Warning: I found no sonar, deactivating.&quot;</span>);</div><div class="line">    deactivate(); </div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  This is the guts of the Turn action.</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><a class="code" href="classArActionDesired.html">ArActionDesired</a> *ActionTurn::fire(<a class="code" href="classArActionDesired.html">ArActionDesired</a> currentDesired)</div><div class="line">{</div><div class="line">  <span class="keywordtype">double</span> leftRange, rightRange;</div><div class="line">  <span class="comment">// reset the actionDesired (must be done)</span></div><div class="line">  myDesired.<a class="code" href="classArActionDesired.html#ade8f095f408b4ed5e638bb4a72ad070b">reset</a>();</div><div class="line">  <span class="comment">// if the sonar is null we can&#39;t do anything, so deactivate</span></div><div class="line">  <span class="keywordflow">if</span> (mySonar == NULL)</div><div class="line">  {</div><div class="line">    deactivate();</div><div class="line">    <span class="keywordflow">return</span> NULL;</div><div class="line">  }</div><div class="line">  <span class="comment">// Get the left readings and right readings off of the sonar</span></div><div class="line">  leftRange = (mySonar-&gt;currentReadingPolar(0, 100) - </div><div class="line">        myRobot-&gt;getRobotRadius());</div><div class="line">  rightRange = (mySonar-&gt;currentReadingPolar(-100, 0) - </div><div class="line">        myRobot-&gt;getRobotRadius());</div><div class="line">  <span class="comment">// if neither left nor right range is within the turn threshold,</span></div><div class="line">  <span class="comment">// reset the turning variable and don&#39;t turn</span></div><div class="line">  <span class="keywordflow">if</span> (leftRange &gt; myTurnThreshold &amp;&amp; rightRange &gt; myTurnThreshold)</div><div class="line">  {</div><div class="line">    myTurning = 0;</div><div class="line">    myDesired.setDeltaHeading(0);</div><div class="line">  }</div><div class="line">  <span class="comment">// if we&#39;re already turning some direction, keep turning that direction</span></div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (myTurning)</div><div class="line">  {</div><div class="line">    myDesired.setDeltaHeading(myTurnAmount * myTurning);</div><div class="line">  }</div><div class="line">  <span class="comment">// if we&#39;re not turning already, but need to, and left is closer, turn right</span></div><div class="line">  <span class="comment">// and set the turning variable so we turn the same direction for as long as</span></div><div class="line">  <span class="comment">// we need to</span></div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (leftRange &lt; rightRange)</div><div class="line">  {</div><div class="line">    myTurning = -1;</div><div class="line">    myDesired.setDeltaHeading(myTurnAmount * myTurning);</div><div class="line">  }</div><div class="line">  <span class="comment">// if we&#39;re not turning already, but need to, and right is closer, turn left</span></div><div class="line">  <span class="comment">// and set the turning variable so we turn the same direction for as long as</span></div><div class="line">  <span class="comment">// we need to</span></div><div class="line">  <span class="keywordflow">else</span> </div><div class="line">  {</div><div class="line">    myTurning = 1;</div><div class="line">    myDesired.setDeltaHeading(myTurnAmount * myTurning);</div><div class="line">  }</div><div class="line">  <span class="comment">// return a pointer to the actionDesired, so resolver knows what to do</span></div><div class="line">  <span class="keywordflow">return</span> &amp;myDesired;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">  <a name="a11"></a><a class="code" href="classAria.html#ad99c16b5d947229d9f8e1c5b2d4cdd73">Aria::init</a>();</div><div class="line">  <a name="_a12"></a><a class="code" href="classArArgumentParser.html">ArArgumentParser</a> parser(&amp;argc, argv);</div><div class="line">  parser.<a name="a13"></a><a class="code" href="classArArgumentParser.html#a501694b62a7f8b0c3cadd84aeafe1b35">loadDefaultArguments</a>();</div><div class="line">  <a class="code" href="classArRobot.html">ArRobot</a> robot;</div><div class="line">  <a name="_a14"></a><a class="code" href="classArSonarDevice.html">ArSonarDevice</a> sonar;</div><div class="line"></div><div class="line">  <span class="comment">// Connect to the robot, get some initial data from it such as type and name,</span></div><div class="line">  <span class="comment">// and then load parameter files for this robot.</span></div><div class="line">  <a name="_a15"></a><a class="code" href="classArRobotConnector.html">ArRobotConnector</a> robotConnector(&amp;parser, &amp;robot);</div><div class="line">  <span class="keywordflow">if</span>(!robotConnector.<a name="a16"></a><a class="code" href="classArRobotConnector.html#ab192ac393d9cc1e5b61b1a82b08d085d">connectRobot</a>())</div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;actionExample: Could not connect to the robot.&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span>(parser.<a name="a17"></a><a class="code" href="classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">    {</div><div class="line">        <span class="comment">// -help not given</span></div><div class="line">        <a name="a18"></a><a class="code" href="classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">        <a name="a19"></a><a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">    }</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (!<a name="a20"></a><a class="code" href="classAria.html#a1b090c01d88bb420b8cf8e0384d25ee1">Aria::parseArgs</a>() || !parser.<a class="code" href="classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">  {</div><div class="line">    <a class="code" href="classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">    <a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a21"></a><a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;actionExample: Connected to robot.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// Create instances of the actions defined above, plus ArActionStallRecover, </span></div><div class="line">  <span class="comment">// a predefined action from Aria.</span></div><div class="line">  ActionGo go(500, 350);</div><div class="line">  ActionTurn turn(400, 10);</div><div class="line">  <a name="_a22"></a><a class="code" href="classArActionStallRecover.html">ArActionStallRecover</a> recover;</div><div class="line"></div><div class="line">    </div><div class="line">  <span class="comment">// Add the range device to the robot. You should add all the range </span></div><div class="line">  <span class="comment">// devices and such before you add actions</span></div><div class="line">  robot.<a name="a23"></a><a class="code" href="classArRobot.html#a97d57b28549fdef851c00749a97cc776">addRangeDevice</a>(&amp;sonar);</div><div class="line"></div><div class="line"> </div><div class="line">  <span class="comment">// Add our actions in order. The second argument is the priority, </span></div><div class="line">  <span class="comment">// with higher priority actions going first, and possibly pre-empting lower</span></div><div class="line">  <span class="comment">// priority actions.</span></div><div class="line">  robot.<a name="a24"></a><a class="code" href="group__easy.html#ga9ab030786d423237d3e4aa06c0e9d8ce">addAction</a>(&amp;recover, 100);</div><div class="line">  robot.<a class="code" href="group__easy.html#ga9ab030786d423237d3e4aa06c0e9d8ce">addAction</a>(&amp;go, 50);</div><div class="line">  robot.<a class="code" href="group__easy.html#ga9ab030786d423237d3e4aa06c0e9d8ce">addAction</a>(&amp;turn, 49);</div><div class="line"></div><div class="line">  <span class="comment">// Enable the motors, disable amigobot sounds</span></div><div class="line">  robot.<a name="a25"></a><a class="code" href="group__easy.html#gaa3657bebab0086dd14ed0c8c3f76dc8b">enableMotors</a>();</div><div class="line"></div><div class="line">  <span class="comment">// Run the robot processing cycle.</span></div><div class="line">  <span class="comment">// &#39;true&#39; means to return if it loses connection,</span></div><div class="line">  <span class="comment">// after which we exit the program.</span></div><div class="line">  robot.<a name="a26"></a><a class="code" href="classArRobot.html#a3c1c3056633caf455c8265259f57f6d7">run</a>(<span class="keyword">true</span>);</div><div class="line">  </div><div class="line">  <a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(0);</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
